mui.init();
var dataList;
var wxChannel = null; // 微信支付  
var aliChannel = null; // 支付宝支付  
var channel = null; //支付通道 
mui.init({
	swipeBack: true //启用右滑关闭功能  
});
mui.plusReady(function() {
	var vip_img = ['../../../images/vbg_pt.png', '../../../images/rank_mg_pic.png', '../../../images/rank_by_pic.png',
		'../../../images/rank_hj_pic.png', '../../../images/rank_bj_pic.png', '../../../images/rank_zs_pic.png'
	];
	var vip_in = ['普通会员', '玫瑰会员', '白银会员', '黄金会员', '白金会员', '钻石会员'];
	var self = plus.webview.currentWebview();
	var vip = self.vip;
	var vip_index = self.vip_index;
	var vip_price = self.vip_price;
	dataList = new Vue({
		el: '#dataBOX',
		data: {
			kefu_lists: '',
			custom_id: '',
			consultant_name: '',
			custom_id_bak: '',
			consultant_name_bak: '',
			vip_img: vip_img[vip_index - 1],
			vip_text: vip_in[vip_index - 1],
			vip_price: vip_price,
			pay_type: 'wxpay',
			payway: 'wxpay'
		},
		mounted() {
			this.getCuslist();
			this.getMemberCustomer();
		},
		methods: {
			getMemberCustomer: function() {
				var api_host = plus.storage.getItem('HOST_URL');
				var self = this;
				mui.ajax({
					url: api_host + '/api/cusservice/cusservice/getMemberCustomer',
					dataType: 'json',
					headers: {
						'User-Token': plus.storage.getItem('UserToken')
					},
					type: 'get',
					timeout:3000,
					success: function(msg) {
						self.custom_id = msg.data.custom_id;
						self.consultant_name=msg.data.name;
						self.custom_id_bak = msg.data.custom_id;
						self.consultant_name_bak = msg.data.name;
					},
					error: function() {
						console.log('还未设置专属客服');
					}
				})
			},
			getCuslist: function() {
				var api_host = plus.storage.getItem('HOST_URL');
				var self = this;
				mui.ajax({
					url: api_host + '/api/cusservice/cusservice/cuslist',
					dataType: 'json',
					headers: {
						'User-Token': plus.storage.getItem('UserToken'),
						'special':2
					},
					type: 'get',
					timeout:3000,
					success: function(msg) {
						self.kefu_lists = msg.data;
						plus.nativeUI.closeWaiting();
						mui.currentWebview.show();
					},
					error: function() {
						console.log('获取客服列表出错');
						mui.back();
					}
				})
			},

			choose_li: function(custom_id, name) {
				var self=this;
				self.custom_id_bak = custom_id;
				self.consultant_name_bak = name;
			},

			choose_consultant: function() {
				$('.popMask').show();
				$('.popConsultant').animate({
					'bottom': '0%'
				}, 300).show();
			},

			confirm_custome: function(custom_id, name) {
				var api_host = plus.storage.getItem('HOST_URL');
				var self = this;
				mui.ajax({
					url: api_host + '/api/cusservice/cusservice/addMemberCustomer',
					dataType: 'json',
					data: {
						'custom_id': custom_id,
						'name': name
					},
					headers: {
						'User-Token': plus.storage.getItem('UserToken')
					},
					type: 'post',
					async: true,
					timeout:3000,
					success: function(data) {
						self.consultant_name = name;
						mui.toast(data.msg, {
							duration: '1000',
							type: 'div'
						});
						$('.popMask').hide();
						$('.gwDialog').animate({
							'top': "150%"
						}, 300).hide(300);
					},
					error: function(xhr, type, errorThrown) {
						console.log('系统错误');
					}
				});
				$('.popMask').hide();
				$('.popConsultant').animate({
					'bottom': '-100%'
				}, 300).hide(300);
			},

			yc_kc_gw: function() {
				$('.popMask').hide();
				$('.popConsultant').animate({
					'bottom': '-100%'
				}, 300).hide(300).stop(true, true);

				$('.popMask').hide();
				$('.popPay').animate({
					'bottom': '-100%'
				}, 300).hide(300);
			},
			tijiao_dingdan: function() {
				$('.popMask').show();
				$('.popPay').animate({
					'bottom': '0%'
				}, 300).show();
			},
			pay_way: function(type) {
				this.payway = type;
				this.pay_type = type;
			},
			close_pay_box: function() {
				$('.popMask').hide();
				$('.popPay').animate({
					'bottom': '-100%'
				}, 300).hide(300);
			},
			open_zhifu: function() {
				var goodsInfo = {
					'id': vip,
				};
				new pay().start('vip', this.payway, 1, goodsInfo);
			}
		}
	})
})
